package com.qianfeng.openplateform.search.config;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestClientBuilder;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @author 江江
 * @Date 2020/7/30 10:12
 */
@Configuration
public class EsConfig {
    @Autowired
    private EsProperties ep;
@Bean
public RestHighLevelClient getClient() {
    HttpHost httpHost = new HttpHost(ep.getHost(),ep.getPort());
    RestClientBuilder builder = RestClient.builder(httpHost);
    RestHighLevelClient client = new RestHighLevelClient(builder);
    return client;
}
}
